<div class="nav">
    <a href="{:U('index')}">系统邮箱配置</a>
    <a class="sel">编辑系统邮箱</a>
</div>
<div class="add">
    <form method="post" action="" >
        <table class="table_add">
            <tr>
                <td width="100px">邮箱地址</td>
                <td><input class="input1" type="text" name="email" id="email" value="{$model.email}" style="width:180px" /></td>
            </tr>
            <tr>
                <td>SMTP服务器</td>
                <td><input class="input1" type="text" name="smtp" id="smtp" value="{$model.smtp}" style="width:180px" /></td>
            </tr>
            <tr>
                <td>端口</td>
                <td><input class="input1" type="text" name="port" id="port" value="{$model.port}" style="width:40px" /></td>
            </tr>
            <tr>
                <td>用户名</td>
                <td><input class="input1" type="text" name="username" id="username" value="{$model.username}" style="width:180px" /></td>
            </tr>
            <tr>
                <td>密码</td>
                <td><input class="input1" type="password" name="password2" id="password2" value="" style="width:180px" /> 如果不修改请留空</td>
            </tr>
            <tr><td>启用SSL</td>
                <td><input type="checkbox" name="ssl" id="ssl" value="1" <if condition="$model['ssl'] eq 1">checked="checked"</if> /></td>
            </tr>
            <tr>
                <td width="100px">是否启用</td>
                <td><select name="is_enable" id="is_enable" class="sel1">
                        <option value="1">启用</option>
                        <option value="0">不启用</option>
                    </select> <script type="text/javascript">
                        $("#is_enable").val('{$model.is_enable}');
                    </script> 
                </td>
            </tr>
            <tr>
                <td></td>
                <td><input type="submit" class="btn1" value="提 交" /> &nbsp; <input class="btn4" type="reset" value="重 置" /> &nbsp; <input class="btn3"  type="button" onclick="window.history.back()" value="返 回" /></td>
            </tr>
        </table>
        <input type="hidden" name="id" value="{$model.id}" />
    </form>
    <script type="text/javascript">
        function auto_smtp() {
            var email = $("#email").val();
            var index = email.indexOf('@');
            if(index > 0) {
                var smtp = '';
                var port = '25';
                index++;
                var email_f = email.substring(index,email.length);
                switch(email_f) {
                    case 'sina.com':
                        smtp = 'smtp.sina.com.cn';
                        port:'25';
                        break;
                    case 'vip.sina.com':
                        smtp = 'smtp.vip.sina.com';
                        port:'25';
                        break;
                    case 'sohu.com':
                        smtp = 'smtp.sohu.com';
                        port:'25';
                        break;
                    case '126.com':
                        smtp = 'smtp.126.com';
                        port:'25';
                        break;
                    case '139.com':
                        smtp = 'smtp.139.com';
                        port:'25';
                        break;
                    case '163.com':
                        smtp = 'smtp.163.com';
                        port:'25';
                        break;
                    case 'qq.com':
                        smtp = 'smtp.qq.com';
                        port:'25';
                        break;
                    case 'yahoo.com':
                        smtp = ':smtp.mail.yahoo.com';
                        port:'587';
                        break;
                    case 'gmail.com':
                        smtp = 'smtp.gmail.com';
                        port:'587';
                        break;
                   
                }
                $("#smtp").val(smtp);
                $("#port").val(port);
            } else {
                alert("邮箱格式不对！");
                $("#email").focus();
            }
        }
    </script>
</div>
